﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Logs.Controller;
using Pixysoft.TestDrivens;

namespace Pixysoft.Framework.Logs.testdriven
{
    class tc_007
    {
        public void Initialize()
        {
            LogConfiguration config = new LogConfiguration();
            config.Filename = "a";
            config.LogCapacity = 1;
            config.LogLevel = LogLevel.ALL;
            config.Settings.Add(new LoggerSetting());
            config.Settings[0].Filename = "b";
            config.Settings[0].LogCapacity = 2;
            config.Settings[0].LogLevel = LogLevel.DEBUG;

            SettingController.Initialize(config);
        }

        public void getSetting()
        {
            LogConfiguration config = new LogConfiguration();
            config.Filename = "a";
            config.LogCapacity = 1000 * 1000 * 3;
            config.LogLevel = LogLevel.ALL;
            config.Settings.Add(new LoggerSetting());
            config.Settings[0].Filename = "b";
            config.Settings[0].LogCapacity = 2;
            config.Settings[0].LogLevel = LogLevel.DEBUG;
            config.Settings[0].Modulename = "mb";

            SettingController.Initialize(config);

            LoggerSetting setting = SettingController.Instance.getSetting("a", "");

            Assert.SaveOrVerify("getsetting", setting);

            setting = SettingController.Instance.getSetting("b", "mb");

            Assert.SaveOrVerify("getsetting.module", setting);

            setting = SettingController.Instance.getSetting("c", "mb");

            Assert.SaveOrVerify("getsetting.module.c", setting);


            //test root

            setting = SettingController.Instance.getSetting("hello", "");
            setting.LogCapacity = 123123123;

            setting = SettingController.Instance.getSetting("hello", "sub");
            Assert.SaveOrVerify("getsetting.module.root", setting);
        }

        public void getGroupSetting()
        {
            LogConfiguration config = new LogConfiguration();
            config.Filename = "a";
            config.LogCapacity = 1000 * 1000 * 3;
            config.LogLevel = LogLevel.ALL;
            config.Settings.Add(new LoggerSetting());
            config.Settings[0].Filename = "b";
            config.Settings[0].LogCapacity = 2;
            config.Settings[0].LogLevel = LogLevel.DEBUG;
            config.Settings[0].Modulename = "mb";

            SettingController.Initialize(config);

            Assert.SaveOrVerify("group", SettingController.Instance.getGroupSetting("a"));
        }
    }
}
